<template>
  <IconWrapper>
    <div class="icons_item_wrapper" v-for="item in state" :key="item">
      <IconItem v-for="icon in item" :key="icon.id" :data="icon"></IconItem>
    </div>
  </IconWrapper>
</template>

<script>
import { onBeforeMount, reactive } from "vue";
import IconWrapper from "@/common/IconWrapper/index.vue";
import IconItem from "../IconItem/index.vue";
import request from "@/api/default.js";
export default {
  components: {
    IconItem,
    IconWrapper,
  },
  setup() {
    const state = reactive([]);
    onBeforeMount(async () => {
      const data = await request("/icon");
      let temp = [];
      for (let i = 0; i < data.data.length; i++) {
        temp.push(data.data[i]);
        if (temp.length === 2) {
          state.push(temp);
          temp = [];
        }
      }
    });

    return {
      state,
    };
  },
};
</script>

<style scoped>
.icons_item_wrapper {
  display: flex;
  flex-direction: column;
  margin-left: 20px;
}
.icons_item_wrapper:first-child {
  margin-left: 0;
}
</style>